<template>
  <div class="container">
      <group title="请填写账号">
        <x-input type="tel" v-model.trim="username" :show-clear="false" :debounce="500" placeholder='请填写账号' mask="999 9999 9999" :max="13"></x-input>
      </group>
      <group title="请填写密码">
        <x-input type="password"   v-model.trim="passwd" :show-clear="false" :debounce="500" placeholder='请填写密码' ></x-input>
      </group>
        <x-button @click.native.once="login"  type="primary" action-type="button">登录</x-button> 
  </div>
</template>

<script type="application/ecmascript">
  import * as types from '@/vuex/types'
  import { Group,XInput,XButton} from 'vux'
  export default {
    components: {
      Group,
      XInput,
      XButton
    },
    name: 'login',
    data () {
      return {
        token: '',
        passwd:'',
        username:'',
      }
    },
    mounted(){
      let token = this.$route.params.openid
      this.$store.commit('login/'+types.LOGIN,{token})
    },
    methods: {
      login(){
        if(this.passwd){
          let token = this.$route.params.openid
          this.$store.dispatch(types.CHILDLOGIN,[this.passwd,this.username,token])
        }
      }
    }
  }
</script>